/**
 * @author caojj
 */
/***************************路径解析****************************/
try{XN}catch(ex){XN={}};
function getHostSuffix(){
	var matcher = location.host.match(/\.(.*\..*)/i);
	hostSuffix = matcher && matcher[1];
	return hostSuffix || "d1xn.com";
}

XN.GlobalPath={};
XN.GlobalPath.userfile={};
XN.GlobalPath.userfile.LevelNum=5;
XN.GlobalPath.userfile.PerNum=100;
XN.GlobalPath.userfile.ResPath="/res/public/userfile/";

XN.GlobalPath.blogspace={};
XN.GlobalPath.blogspace.LevelNum=4;
XN.GlobalPath.blogspace.PerNum=1000;
XN.GlobalPath.blogspace.ResPath="/res/public/blogspace/";

XN.GlobalPath.imagespace={};
XN.GlobalPath.imagespace.LevelNum=4;
XN.GlobalPath.imagespace.PerNum=1000;
XN.GlobalPath.imagespace.ResPath="http://resimage."+getHostSuffix()+"/image/";

XN.GlobalPath.videospace={};
XN.GlobalPath.videospace.LevelNum=4;
XN.GlobalPath.videospace.PerNum=1000;
XN.GlobalPath.videospace.ResPath="http://resvideo."+getHostSuffix()+"/video/";

XN.GlobalPath.musicspace={};
XN.GlobalPath.musicspace.LevelNum=4;
XN.GlobalPath.musicspace.PerNum=1000;
XN.GlobalPath.musicspace.ResPath="http://resmusic."+getHostSuffix()+"/music/";

XN.GlobalPath.profile={};
XN.GlobalPath.profile.LevelNum=5;
XN.GlobalPath.profile.PerNum=100;
XN.GlobalPath.profile.ResPath="/profile/";

XN.GlobalPath.www="";

XN.PathParse = function(resId, type){
	var userRootStr = "";
	var gene = 1;
	var LevelNum = XN.GlobalPath[type].LevelNum;
	var PerNum = XN.GlobalPath[type].PerNum;
	var ResPath = XN.GlobalPath[type].ResPath
	for (var i = 1; i < LevelNum; i++) {
		gene *= PerNum;
	}
	var tempUserID = parseInt(resId);
	for (var i = 0; i < LevelNum; i++) {
		if (LevelNum != i + 1) {
			var temp = Math.floor(tempUserID / gene);
			tempUserID = tempUserID % gene;
			userRootStr += temp + "/";
			gene /= PerNum;
		} else {
			userRootStr += resId;
		}
	}
	return ResPath + userRootStr + "/";
}
